﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using jajaja;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using DIMP_Libraries;
using TetroxNetwork;

namespace tetrox_3D
{
    class gameManager
    {
        private KeyboardState LastKeyboardState;

        public Vector2 Position;
        public Vector2 Taille;

        private List<voxel> Explosion;
        private int rayon;
        private Color CouleurExplo;
        private Vector3 CentreExplo;

        private cameraSet[] CameraSets;

        private List<voxel> Bord;
        private bool Ghost;
        private double CameraMoveStart;
        private double CameraMoveTarget;
        private cameraSet CameraSetStart;
        private cameraSet CameraSetTarget;
        public Color CouleurGrille;
        public Color CouleurScore;

        #region Accesseurs

        private int _posScore;
        public int posScore
        {
            get { return _posScore; }
            set { _posScore = value; }
        }

        private int _Lignes;
        public int Lignes
        {
            get { return _Lignes; }
            set { _Lignes = value; }
        }
        

        private int _Level;
        public int Level
        {
            get { return _Level; }
            set { _Level = value; }
        }
        
        private int _Score;
        public int Score
        {                         
            get { return _Score; }
            set { _Score = value; }
        }
        
        private SoundEffect _SoundBouge;
        public SoundEffect SoundBouge
        {
            get { return _SoundBouge; }
            set { _SoundBouge = value; }
        }
        private SoundEffect _SoundDrop;
        public SoundEffect SoundDrop
        {
            get { return _SoundDrop; }
            set { _SoundDrop = value; }
        }

        private SoundEffect _SoundLigne;
        public SoundEffect SoundLigne
        {
            get { return _SoundLigne; }
            set { _SoundLigne = value; }
        }

        private Random _Randomeur;
        public Random Randomeur
        {
            get { return _Randomeur; }                     
            set { _Randomeur = value; }
        }

        private piece _MainPiece;
        public piece MainPiece
        {
            get { return _MainPiece; }
            set { _MainPiece = value; }
        }

        private List<voxel> _Sol;
        public List<voxel> Sol
        {
            get { return _Sol; }
            set { _Sol = value; }
        }
        

        private List<piece> _Pieces;
        public List<piece> Pieces
        {
            get { return _Pieces; }
            set { _Pieces = value; }
        }

        private double _Timer;
        public double Timer
        {
            get { return _Timer; }
            set { _Timer = value; }
        }

        private int _Delay;
        public int Delay
        {
            get { return _Delay; }
            set { _Delay = value; }
        }

        private camera _Camera;
        public camera Camera
        {
            get { return _Camera; }
            set { _Camera = value; }
        }

        private List<voxel> _Voxels;
        public List<voxel> Voxels
        {
            get { return _Voxels; }
            set { _Voxels = value; }
        }
#endregion

        public void MoveCamera(GameTime Time)
        {
            if (this.CameraMoveTarget > Time.TotalGameTime.TotalMilliseconds)
            {
                this.Camera.Position.X = (float)(this.CameraSetStart.Position.X + (this.CameraSetTarget.Position.X - this.CameraSetStart.Position.X) * (Time.TotalGameTime.TotalMilliseconds - this.CameraMoveStart) / (this.CameraMoveTarget - this.CameraMoveStart));
                this.Camera.Position.Y = (float)(this.CameraSetStart.Position.Y + (this.CameraSetTarget.Position.Y - this.CameraSetStart.Position.Y) * (Time.TotalGameTime.TotalMilliseconds - this.CameraMoveStart) / (this.CameraMoveTarget - this.CameraMoveStart));
                this.Camera.Position.Z = (float)(this.CameraSetStart.Position.Z + (this.CameraSetTarget.Position.Z - this.CameraSetStart.Position.Z) * (Time.TotalGameTime.TotalMilliseconds - this.CameraMoveStart) / (this.CameraMoveTarget - this.CameraMoveStart));
                this.Camera.Orientation.X = (float)(this.CameraSetStart.Orientation.X + (this.CameraSetTarget.Orientation.X - this.CameraSetStart.Orientation.X) * (Time.TotalGameTime.TotalMilliseconds - this.CameraMoveStart) / (this.CameraMoveTarget - this.CameraMoveStart));
                this.Camera.Orientation.Y = (float)(this.CameraSetStart.Orientation.Y + (this.CameraSetTarget.Orientation.Y - this.CameraSetStart.Orientation.Y) * (Time.TotalGameTime.TotalMilliseconds - this.CameraMoveStart) / (this.CameraMoveTarget - this.CameraMoveStart));
                this.Camera.FOV = (float)(this.CameraSetStart.FOV + (this.CameraSetTarget.FOV - this.CameraSetStart.FOV) * (Time.TotalGameTime.TotalMilliseconds - this.CameraMoveStart) / (this.CameraMoveTarget - this.CameraMoveStart));
            }
            else
            {
                this.Camera.Position = this.CameraSetTarget.Position;
                this.Camera.Orientation = this.CameraSetTarget.Orientation;
                this.Camera.FOV = this.CameraSetTarget.FOV;
            }
            if (this.CouleurGrille.R != 0 || this.CouleurGrille.G != 0 || this.CouleurGrille.B != 0)
            {
                this.CouleurGrille.R = (byte)(this.CouleurGrille.R / 1.1);
                this.CouleurGrille.G = (byte)(this.CouleurGrille.G / 1.1);
                this.CouleurGrille.B = (byte)(this.CouleurGrille.B / 1.1);
            }
            if (this.CouleurScore.R != 0 || this.CouleurScore.G != 0 || this.CouleurScore.B != 0)
            {
                this.CouleurScore.R = (byte)(this.CouleurScore.R / 1.1);
                this.CouleurScore.G = (byte)(this.CouleurScore.G / 1.1);
                this.CouleurScore.B = (byte)(this.CouleurScore.B / 1.1);
            }
        }

        public bool Update(GameTime gameTime, ClientServeur sunaorp)
        {
            #region CACA
            bool hasMoved = false;

            if (Keyboard.GetState().IsKeyDown(Keys.A))
                this.Camera.Orientation.X -= (float)(Math.PI / 180);
            if (Keyboard.GetState().IsKeyDown(Keys.E))
                this.Camera.Orientation.X += (float)(Math.PI / 180);
            if (Keyboard.GetState().IsKeyDown(Keys.R))
                this.Camera.Orientation.Y += (float)(Math.PI / 180);
            if (Keyboard.GetState().IsKeyDown(Keys.F))
                this.Camera.Orientation.Y -= (float)(Math.PI / 180);
            if (Keyboard.GetState().IsKeyDown(Keys.Down))
            {
                    piece tempPiece = new piece();
                    tempPiece.Position = this.MainPiece.Position;
                    tempPiece.Voxels = this.MainPiece.Voxels;
                    tempPiece.Position.Y--;
                    if (!this.Collide(tempPiece))
                    {
                        this.MainPiece.Position.Y--;
                        hasMoved = true;
                    }
                this.Timer = 0;
            }
            if (Keyboard.GetState().IsKeyDown(Keys.Space) && this.LastKeyboardState.IsKeyUp(Keys.Space))
            {
                piece tempPiece = new piece();
                tempPiece.Position = this.MainPiece.Position;
                tempPiece.Voxels = this.MainPiece.Voxels;
                tempPiece.Position.Y--;
                while (!this.Collide(tempPiece))
                {
                    this.MainPiece.Position = tempPiece.Position;
                    tempPiece.Position.Y--;
                }
                hasMoved = true;
                this.Timer = 0;
            }
            if (Keyboard.GetState().IsKeyDown(Keys.LeftControl))
                this.Camera.Position.Y--;
            if (Keyboard.GetState().IsKeyDown(Keys.Left) && this.LastKeyboardState.IsKeyUp(Keys.Left))
            {
                piece tempPiece = new piece();
                tempPiece.Position = this.MainPiece.Position;
                tempPiece.Voxels = this.MainPiece.Voxels;
                tempPiece.Position.X++;
                if (!this.Collide(tempPiece))
                {
                    this.MainPiece.Position = tempPiece.Position;
                    hasMoved = true;
                    this.SoundBouge.Play();
                }
            }
            if (Keyboard.GetState().IsKeyDown(Keys.G) && this.LastKeyboardState.IsKeyUp(Keys.G))
                if (this.Ghost)
                    this.Ghost = false;
                else
                    this.Ghost = true;

            if (Keyboard.GetState().IsKeyDown(Keys.Up) && this.LastKeyboardState.IsKeyUp(Keys.Up))
            {
                piece tempPiece = new piece();
                tempPiece.Position = this.MainPiece.Position;
                tempPiece.Voxels = this.MainPiece.Voxels;
                if (!this.Collide(this.Rotate(tempPiece)))
                {
                    this.MainPiece = this.Rotate(this.MainPiece);
                    hasMoved = true;
                }
            }
            if (Keyboard.GetState().IsKeyDown(Keys.Right) && this.LastKeyboardState.IsKeyUp(Keys.Right))
            {
                piece tempPiece = new piece();
                tempPiece.Position = this.MainPiece.Position;
                tempPiece.Voxels = this.MainPiece.Voxels;
                tempPiece.Position.X--;
                if (!this.Collide(tempPiece))
                {
                    this.MainPiece.Position = tempPiece.Position;
                    this.SoundBouge.Play();
                    hasMoved = true;
                }
            }
            if (Keyboard.GetState().IsKeyDown(Keys.F1) && this.LastKeyboardState.IsKeyDown(Keys.F1))
            {
                this.CameraSetStart.Position = this.Camera.Position;
                this.CameraSetStart.Orientation = this.Camera.Orientation;
                this.CameraSetStart.FOV = this.Camera.FOV;
                this.CameraSetTarget = this.CameraSets[this.Randomeur.Next(0, 7)];
                this.CameraMoveStart = gameTime.TotalGameTime.TotalMilliseconds;
                this.CameraMoveTarget = gameTime.TotalGameTime.TotalMilliseconds + 1000;
            }
            if (Keyboard.GetState().IsKeyDown(Keys.Q))
            {
                this.Camera.Position.X += (float)(Math.Cos(this.Camera.Orientation.X - Math.PI / 2) * Math.Cos(this.Camera.Orientation.Y));
                this.Camera.Position.Y -= (float)Math.Sin(this.Camera.Orientation.Y);
                this.Camera.Position.Z -= (float)(Math.Sin(this.Camera.Orientation.X - Math.PI / 2) * Math.Cos(this.Camera.Orientation.Y));
                //this.Camera.Position.X++;
            }
            if (Keyboard.GetState().IsKeyDown(Keys.D))
            {
                this.Camera.Position.X += (float)(Math.Cos(this.Camera.Orientation.X + Math.PI / 2) * Math.Cos(this.Camera.Orientation.Y));
                this.Camera.Position.Y -= (float)Math.Sin(this.Camera.Orientation.Y);
                this.Camera.Position.Z -= (float)(Math.Sin(this.Camera.Orientation.X + Math.PI / 2) * Math.Cos(this.Camera.Orientation.Y));
                //this.Camera.Position.X++;
            }
            if (Keyboard.GetState().IsKeyDown(Keys.Z))
            {
                this.Camera.Position.X += (float)(Math.Cos(this.Camera.Orientation.X) * Math.Cos(this.Camera.Orientation.Y));
                this.Camera.Position.Y -= (float)Math.Sin(this.Camera.Orientation.Y);
                this.Camera.Position.Z -= (float)(Math.Sin(this.Camera.Orientation.X) * Math.Cos(this.Camera.Orientation.Y));
                //this.Camera.Position.X++;
            }
            if (Keyboard.GetState().IsKeyDown(Keys.S))
            {
                this.Camera.Position.X -= (float)(Math.Cos(this.Camera.Orientation.X) * Math.Cos(this.Camera.Orientation.Y));
                this.Camera.Position.Y += (float)Math.Sin(this.Camera.Orientation.Y);
                this.Camera.Position.Z += (float)(Math.Sin(this.Camera.Orientation.X) * Math.Cos(this.Camera.Orientation.Y));
                //this.Camera.Position.X--;
            }
            if (Keyboard.GetState().IsKeyDown(Keys.O))
                this.Camera.FOV -= 0.03;
            if (Keyboard.GetState().IsKeyDown(Keys.P))
                this.Camera.FOV += 0.03;
            if (Keyboard.GetState().IsKeyDown(Keys.K))
                this.Voxels.Clear();
            if (Keyboard.GetState().IsKeyDown(Keys.M))
                this.Camera.TypeDessin = camera.dessin.arretes;
            if (Keyboard.GetState().IsKeyDown(Keys.L))
                this.Camera.TypeDessin = camera.dessin.pleins;
            if (Keyboard.GetState().IsKeyDown(Keys.J))
                this.Camera.TypeDessin = camera.dessin.full;
            #endregion

            if (this.Timer < gameTime.TotalGameTime.TotalMilliseconds)
            {
                this.Timer = gameTime.TotalGameTime.TotalMilliseconds + this.Delay;
                piece pieceTest = new piece();
                pieceTest.Position = this.MainPiece.Position;
                pieceTest.Voxels = this.MainPiece.Voxels;
                pieceTest.TypePiece = this.MainPiece.TypePiece;
                pieceTest.Position.Y--;
                if (!this.Collide(pieceTest))
                {
                    this.MainPiece.Position.Y--;
                    hasMoved = true;
                }
                else
                {
                    this.Voxels.AddRange(MainPiece.AbsoluteVoxels());
                    this.CouleurGrille = this.MainPiece.Voxels.First().Couleur;
                    this.SoundDrop.Play();
                    this.rayon = 0;
                    //this.Camera.FOV += 0.1;
                    this.CentreExplo = new Vector3(this.MainPiece.Position.X * 10 + 10, 0, this.MainPiece.Position.Y * 10);
                    this.CouleurExplo = this.MainPiece.Voxels.First().Couleur;
                    this.MainPiece = this.Pieces.First();
                    this.Pieces.Remove(this.Pieces.First());
                    this.Pieces.Add(new piece((Type)this.Randomeur.Next(0, 7)));
                    this.MainPiece.Position = new Vector2(3, this.Taille.Y);

                    //test ligne
                    int ligneScored = 0;
                    for (int i = 0; i < this.Taille.Y * 10; i += 10)
                    {
                        if (this.Voxels.Where(b => b.position.Y == i).Count() >= 10)
                        {
                            #region Ligne Scored
                            //this._SoundLigne.Play();
                            //this.CameraSetStart.Position = this.Camera.Position;
                            //this.CameraSetStart.Orientation = this.Camera.Orientation;
                            //this.CameraSetStart.FOV = this.Camera.FOV;
                            //this.CameraSetTarget = this.CameraSets[this.Randomeur.Next(0, 7)];
                            //this.CameraMoveStart = gameTime.TotalGameTime.TotalMilliseconds;
                            //this.CameraMoveTarget = gameTime.TotalGameTime.TotalMilliseconds + 1000;
                            ligneScored++;

                            List<voxel> toDelete = new List<voxel>();
                            toDelete.AddRange(this.Voxels.Where(b => b.position.Y == i));
                            foreach (var item in toDelete)
                                this.Voxels.Remove(item);
                            foreach (var item in this.Voxels.Where(b => b.position.Y >= i))
                                item.position.Y -= 10;
                            i -= 10;
                            #endregion
                        }
                    }
                    #region envoi nouvelle map
                    netMap sltsava = new netMap();
                    foreach (var item in this.Voxels)
                    {
                        netBlock cc = new netBlock();
                        cc.Position.X = item.position.X / 10;
                        cc.Position.Y = item.position.Y / 10;
                        cc.Couleur = item.Couleur;
                        sltsava.Map.Add(cc);
                    }
                    sunaorp.SendMessage(sltsava);
                    #endregion
                    #region score
                    if (ligneScored > 0)
                    {
                        this.Lignes += ligneScored;
                        this.CouleurScore = Color.Tomato;
                        int facteur = 0;
                        int ampliMulti = 0;
                        switch (ligneScored)
                        {
                            case 1:
                                ampliMulti = 1;
                                facteur = 40;
                                break;
                            case 2:
                                ampliMulti = 3;
                                facteur = 100;
                                break;
                            case 3:
                                ampliMulti = 7;
                                facteur = 300;
                                break;
                            case 4:
                                ampliMulti = 15;
                                facteur = 1200;
                                break;
                            default:
                                break;
                        }
                        //this.Score += (this.Level + 1) / 10 * facteur;
                        //this.Level = this.Lignes / 10;
                        //this.Delay = (int)(1000 / (2 * (1 + ((float)this.Level / 10))));
                        //this.posScore = 5;
                        #region envoi kekette
                        netAttaque ATTAK = new netAttaque();
                        ATTAK.Amplitude = ampliMulti;
                        sunaorp.SendMessage(ATTAK);
                        #endregion
                    }
                    #endregion
                }
            }

            if (hasMoved)
            {
                netPiece cacacul = new netPiece();
                cacacul.Position = MainPiece.Position;
                foreach (var item in MainPiece.Voxels)
                {
                    netBlock sauce = new netBlock();
                    sauce.Position.X = item.position.X;
                    sauce.Position.Y = item.position.Y;
                    sauce.Couleur = item.Couleur;
                    cacacul.Blocks.Add(sauce);
                }
                sunaorp.SendMessage(cacacul);
            } 

            else
                this.Timer++;

            this.MoveCamera(gameTime);
            this.LastKeyboardState = Keyboard.GetState();

            if (this.rayon < 500)
                this.rayon += 14;

            if (this.posScore > -250)
                this.posScore -= 15;

            if (this.Voxels.Where(b => b.position.Y > 230).Count() > 0)
                return false;
            else
                return true;

            
        }
        public bool Collide(piece Piece)
        {
            bool collide = false;

            foreach (var item in Piece.AbsoluteVoxels())
                if (this.Voxels.Where(b => b.position.X == item.position.X && b.position.Y == item.position.Y).Count() > 0
                    || item.position.Y < 1
                    || item.position.X < 0
                    || item.position.X > (this.Taille.X - 1) * 10)
                    collide = true;

            return collide;
        }

        public piece Rotate(piece Piece)
        {
            piece tempPiece = new piece();
            if (Piece.TypePiece == Type.barre)
            {
                tempPiece.Position = Piece.Position;
                foreach (var item in Piece.Voxels)
                {
                    voxel newVox = new voxel();
                    newVox.Couleur = item.Couleur;
                    newVox.position = new Vector3(item.position.Y, 3 - item.position.X, 0);
                    tempPiece.Voxels.Add(newVox);
                }
            }
            else
            {
                tempPiece.Position = Piece.Position;
                foreach (var item in Piece.Voxels)
                {
                    voxel newVox = new voxel();
                    newVox.Couleur = item.Couleur;
                    newVox.position = new Vector3(item.position.Y, 2 - item.position.X, 0);
                    tempPiece.Voxels.Add(newVox);
                }
            }

            return tempPiece;
        }

        public void Draw()
        {
            List<voxel> toDraw = new List<voxel>();
            #region Draw Ghost
            if (this.Ghost)
            {
                piece Ghost = new piece();
                Color ColorSave = this.MainPiece.Voxels.First().Couleur;
                Ghost.Position = this.MainPiece.Position;
                Ghost.Voxels.AddRange(this.MainPiece.Voxels);
                foreach (var item in Ghost.Voxels)
                    item.Couleur = Color.Gray;
                while (!this.Collide(Ghost))
                    Ghost.Position.Y--;
                Ghost.Position.Y++;
                toDraw.AddRange(Ghost.AbsoluteVoxels());
                foreach (var item in this.MainPiece.Voxels)
                    item.Couleur = ColorSave;
            }
#endregion
            #region Draw Bord
            foreach (var item in this.Bord)
                item.Couleur = this.CouleurGrille;
            toDraw.AddRange(this.Bord);
#endregion
            #region Draw Explo etc.
            voxel temp;
            if (this.rayon < 500)
            {
                for (int i = 0; i < 100; i++)
                {
                    temp = new voxel();
                    temp.position = new Vector3((float)((int)((this.rayon * Math.Cos(i * Math.PI / 50) + this.CentreExplo.X) / 10) * 10), -10, (float)((int)((this.rayon * Math.Sin(i * Math.PI / 50)) / 10) * 10));
                    temp.Couleur = this.CouleurExplo;
                    toDraw.Add(temp);
                }
            }
            #endregion
            #region Draw Pieces
            int y = 0;
            foreach (var item in this.Pieces)
            {
                foreach (var item2 in item.Voxels)
	{
                    voxel tempvox = new voxel();
                    tempvox.Couleur = item2.Couleur;
                    tempvox.position = new Vector3(150 -item2.position.X * 10, 220 - y * 10 - item2.position.Y * 10, 0);
                    toDraw.Add(tempvox);
	}
                
                y += 4;
            }
            #endregion
            #region Draw Sol
            //toDraw.AddRange(this.Sol);
            #endregion
            #region Draw Contenu
            toDraw.AddRange(this.Voxels);
            toDraw.AddRange(this.MainPiece.AbsoluteVoxels());
            //foreach (var item in this.Pieces)
            //{
            //    toDraw.AddRange(item.Voxels);
            //}
            #endregion
            #region Draw Score
            int x = 0;
            foreach (char item in this.Score.ToString())
            {
                foreach (Vector2 item2 in caractere.getCoords(item))
                {
                    voxel tempVox = new voxel();
                    tempVox.position = new Vector3(-200 - 50 * x - item2.X * 10, 150 - item2.Y * 10, this.posScore);
                    tempVox.Couleur = this.CouleurScore;
                    toDraw.Add(tempVox);
                }
                x++;
            }
            x = 0;
            foreach (char item in this.Lignes.ToString())
            {
                foreach (Vector2 item2 in caractere.getCoords(item))
                {
                    voxel tempVox = new voxel();
                    tempVox.position = new Vector3(-200 - 50 * x - item2.X * 10, 80 - item2.Y * 10, -250);
                    tempVox.Couleur = this.CouleurScore;
                    toDraw.Add(tempVox);
                }
                x++;
            }
            x = 0;
            foreach (char item in this.Level.ToString())
            {
                foreach (Vector2 item2 in caractere.getCoords(item))
                {
                    voxel tempVox = new voxel();
                    tempVox.position = new Vector3(-200 - 50 * x - item2.X * 10, 10-item2.Y * 10, -250);
                    tempVox.Couleur = this.CouleurScore;
                    toDraw.Add(tempVox);
                }
                x++;
            }
            #endregion
            this.Camera.DrawVoxels(toDraw);
        }

        public gameManager()
        {
            #region Random Shits
            this.Randomeur = new Random();
            this.CouleurScore = Color.White;
            this.Lignes = 0;
            this.Score = 0;
            this.posScore = -250;
            this.Level = 0;
            this.LastKeyboardState = Keyboard.GetState();
            this.Voxels = new List<voxel>();
            this.Pieces = new List<piece>();
            this.Pieces.Add(new piece((Type)this.Randomeur.Next(0, 7)));
            this.Pieces.Add(new piece((Type)this.Randomeur.Next(0, 7)));
            this.Pieces.Add(new piece((Type)this.Randomeur.Next(0, 7)));
            this.Delay = 500;
            this.Timer = 0;
            this.Ghost = true;
            this.Position = new Vector2(0, 0);
            this.Taille = new Vector2(10, 24);
            this.MainPiece = new piece((Type)this.Randomeur.Next(0, 6));
            this.MainPiece.Position = new Vector2(2, this.Taille.Y);
            this.rayon = 500;
            this.Explosion = new List<voxel>();
            this.CentreExplo = new Vector3(0, 0, 0);
            this.CameraMoveTarget = 0;
            #endregion
            #region Camera Sets
            this.CameraSets = new cameraSet[15];
            cameraSet temp = new cameraSet();
            temp.Position = new Vector3(128, -139, 144);
            temp.Orientation = new Vector2(2, -0.95f);
            temp.FOV = 0.6;
            CameraSets[0] = temp;
            temp = new cameraSet();
            temp.Position = new Vector3(133, 236, 140);
            temp.Orientation = new Vector2(2.24f, 0.67f);
            temp.FOV = 1.14;
            CameraSets[1] = temp;
            temp = new cameraSet();
            temp.Position = new Vector3(-401, 196, 311);
            temp.Orientation = new Vector2(0.62f, 0.15f);
            temp.FOV = 0.39;
            CameraSets[2] = temp;
            temp = new cameraSet();
            temp.Position = new Vector3(60, 238, 72);
            temp.Orientation = new Vector2(1.49f, 0.98f);
            temp.FOV = 1.26;
            CameraSets[3] = temp;
            temp = new cameraSet();
            temp.Position = new Vector3(28, -25, 61);
            temp.Orientation = new Vector2(1.21f, -1.01f);
            temp.FOV = 1.26;
            CameraSets[4] = temp;
            temp = new cameraSet();
            temp.Position = new Vector3(-9, 125, 119);
            temp.Orientation = new Vector2(1.21f, 0.15f);
            temp.FOV = 1.32f;
            CameraSets[5] = temp;
            temp = new cameraSet();
            temp.Position = new Vector3(99, 227, 63);
            temp.Orientation = new Vector2(2.07f, 0.79f);
            temp.FOV = 1.8;
            CameraSets[6] = temp;
            temp = new cameraSet();
            temp.Position = new Vector3(215, 184, 401);
            temp.Orientation = new Vector2(2, (float)0.18);
            temp.FOV = 0.6;
            CameraSets[7] = temp;
            #endregion
            #region Bords
            this.Bord = new List<voxel>();
            voxel bord;
            for (int i = 1; i < (this.Taille.Y + 1); i++)
            {
                bord = new voxel();
                bord.position = new Vector3(-10, i * 10, 0);
                bord.Couleur = Color.Black;
                this.Bord.Add(bord);
                bord = new voxel();
                bord.position = new Vector3(this.Taille.X * 10, i * 10, 0);
                bord.Couleur = Color.Black;
                this.Bord.Add(bord);
            }
            #endregion
            #region Sol
            this.Sol = new List<voxel>();
            voxel sol;
            for (int i = 1; i < 20; i++)
            {
                for (int j = 0; j < 20; j++)
                {
                    sol = new voxel();
                    sol.position = new Vector3(150 - i * 10, 0, 100 - j * 10);
                    sol.Couleur = Color.Black;
                    this.Sol.Add(sol);
                }

            }
            #endregion
        }
        public gameManager(camera Camera)
            : this()
        {
            this.Camera = Camera;
            this.CameraSetStart = new cameraSet();
            this.CameraSetTarget = new cameraSet();
            this.CameraSetTarget.Position = this.Camera.Position;
            this.CameraSetTarget.Orientation = this.Camera.Orientation;
            this.CameraSetTarget.FOV = this.Camera.FOV;
        }
        public gameManager(camera Camera, ContentManager Content)
            : this(Camera)
        {
            this.SoundBouge = Content.Load<SoundEffect>("SoundBouge");
            this.SoundDrop = Content.Load<SoundEffect>("SoundDrop");
            this._SoundLigne = Content.Load<SoundEffect>("SoundLigne");
        }
    }
}
